package model;
import java.awt.Graphics;
import java.awt.Point;
import java.util.Observable;


public abstract class DrawObject extends Observable 
{
	protected int x1, y1, x2, y2, x3, y3, x4, y4;
	protected int width, height, thickness;
	protected int red, green, blue;
	protected String text;
	
	protected char type;
	
	protected int sel_char_index = -1;
	
	
	public DrawObject( )
	{
		
	}
	
	public DrawObject(DrawObject obj) 
	{
		this.x1 = obj.x1;
		this.y1 = obj.y1;
		this.x2 = obj.x2;
		this.y2 = obj.y2;
		this.x3 = obj.x3;
		this.y3 = obj.y3;
		this.x4 = obj.x4;
		this.y4 = obj.y4;
		this.width = obj.width;
		this.height = obj.height;
		this.thickness = obj.thickness;
		this.red = obj.red;
		this.green = obj.green;
		this.blue = obj.blue;
		
		if (obj.text == null)
			this.text = null;
		else
			this.text = new String(obj.text);
		
		this.type = obj.type;
		this.sel_char_index = obj.sel_char_index;
	}


//	protected  void initVars()
//	{
//		x1 = -1;
//		y1 = -1;
//		x2 = -1;
//		y2 = -1;
//		x3 = -1;
//		y3 = -1;
//		x4 = -1;
//		y4 = -1;
//		
//		width = -1;
//		height = -1;
//		thickness = -1;
//		
//		red = -1;
//		green = -1;
//		blue = -1;
//		
//		text = null;
//		type = 0;
//	}
	
	
	/*
	 * ******************************************
	 * 				Getters & Setters
	 * ******************************************
	 * 
	 */
	
	public int getX1() {
		return x1;
	}
	
	
	public char getType() {
		return type;
	}

	public void setX1(int x1) {
		this.x1 = x1;
		this.setChanged();
		this.notifyObservers();
	}


	public int getY1() {
		return y1;
	}


	public void setY1(int y1) {
		this.y1 = y1;
		this.setChanged();
		this.notifyObservers();
	}


	public int getX2() {
		return x2;
	}


	public void setX2(int x2) {
		this.x2 = x2;
		this.setChanged();
		this.notifyObservers();
	}


	public int getY2() {
		return y2;
	}


	public void setY2(int y2) {
		this.y2 = y2;
		this.setChanged();
		this.notifyObservers();
	}


	public int getX3() {
		return x3;
	}


	public void setX3(int x3) {
		this.x3 = x3;
		this.setChanged();
		this.notifyObservers();
	}


	public int getY3() {
		return y3;
	}


	public void setY3(int y3) {
		this.y3 = y3;
		this.setChanged();
		this.notifyObservers();
	}


	public int getX4() {
		return x4;
	}


	public void setX4(int x4) {
		this.x4 = x4;
		this.setChanged();
		this.notifyObservers();
	}


	public int getY4() {
		return y4;
	}


	public void setY4(int y4)
	{
		this.y4 = y4;
		this.setChanged();
		this.notifyObservers();
	}


	public int getWidth() {
		return width;
	}


	public void setWidth(int width)
	{
		this.width = width;
		this.setChanged();
		this.notifyObservers();
	}


	public int getHeight() {
		return height;
	}


	public void setHeight(int height)
	{
		this.height = height;
		this.setChanged();
		this.notifyObservers();
	}


	public int getThickness() {
		return thickness;
	}


	public void setThickness(int thickness)
	{
		this.thickness = thickness;
		this.setChanged();
		this.notifyObservers();
	}


	public int getRed() {
		return red;
	}


	public void setRed(int red)
	{
		this.red = red;
		this.setChanged();
		this.notifyObservers();
	}


	public int getGreen() {
		return green;
	}


	public void setGreen(int green)
	{
		this.green = green;
		this.setChanged();
		this.notifyObservers();
	}


	public int getBlue() {
		return blue;
	}


	public void setBlue(int blue) 
	{
		this.blue = blue;
		this.setChanged();
		this.notifyObservers();
	}


	public String getText() {
		return text;
	}


	public void setText(String text)
	{
		this.text = text;
		this.setChanged();
		this.notifyObservers();
	}
	
	
	
	/*
	 * ******************************************
	 * 				Overrides
	 * ******************************************
	 * 
	 */
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + blue;
		result = prime * result + green;
		result = prime * result + height;
		result = prime * result + red;
		result = prime * result + ((text == null) ? 0 : text.hashCode());
		result = prime * result + thickness;
		result = prime * result + type;
		result = prime * result + width;
		result = prime * result + x1;
		result = prime * result + x2;
		result = prime * result + x3;
		result = prime * result + x4;
		result = prime * result + y1;
		result = prime * result + y2;
		result = prime * result + y3;
		result = prime * result + y4;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DrawObject other = (DrawObject) obj;
		if (blue != other.blue)
			return false;
		if (green != other.green)
			return false;
		if (height != other.height)
			return false;
		if (red != other.red)
			return false;
		if (text == null) {
			if (other.text != null)
				return false;
		} else if (!text.equals(other.text))
			return false;
		if (thickness != other.thickness)
			return false;
		if (type != other.type)
			return false;
		if (width != other.width)
			return false;
		if (x1 != other.x1)
			return false;
		if (x2 != other.x2)
			return false;
		if (x3 != other.x3)
			return false;
		if (x4 != other.x4)
			return false;
		if (y1 != other.y1)
			return false;
		if (y2 != other.y2)
			return false;
		if (y3 != other.y3)
			return false;
		if (y4 != other.y4)
			return false;
		return true;
	}

	
	
}
